//
//  OtherHeader.h
//  DLAppStore
//
//  Created by zhangmengmeng on 14-2-11.
//  Copyright (c) 2014年 Archermind. All rights reserved.
//


#pragma mark - ----------------------Common macros----------------------


#if __has_feature(objc_instancetype)

#undef    DEF_SINGLETON
#define   DEF_SINGLETON( ... )  \
+ (instancetype)sharedInstance;

#undef  IMP_SINGLETON
#define IMP_SINGLETON \
+ (instancetype)sharedInstance \
{ \
static dispatch_once_t once; \
static id __singleton__; \
dispatch_once( &once, ^{ __singleton__ = [[self alloc] init]; } ); \
return __singleton__; \
}

#else

#undef	DEF_SINGLETON
#define DEF_SINGLETON( __class ) \
+ (__class *)sharedInstance;

#undef	IMP_SINGLETON
#define IMP_SINGLETON( __class ) \
+ (__class *)sharedInstance \
{ \
static dispatch_once_t once; \
static __class * __singleton__; \
dispatch_once( &once, ^{ __singleton__ = [[[self class] alloc] init]; } ); \
return __singleton__; \
}

#endif

//是否为 retina屏幕
#define IS_RETINA ([UIScreen instancesRespondToSelector:@selector(scale)] ? (2 == [[UIScreen mainScreen] scale]) : NO)

//375 667

//1920x1080
//1920x1080

//判断是否是iOS7.0及以上
#define IOS_VERSION_7_OR_ABOVE (([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)? (YES):(NO))

#define IOS_8 (([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)? (YES):(NO))
//当前设备是否为 iPhone5
#define IS_IPHONE5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO)

#define IS_IPHONE4 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO)

#define SCREEN_W [[UIScreen mainScreen] bounds].size.width

#define SCREEN_H [[UIScreen mainScreen] bounds].size.height
//当前系统版本
#define CurrentSystemVersion ([[[UIDevice currentDevice] systemVersion] floatValue])

//当前语言
#define CurrentLanguage      ([[NSLocale preferredLanguages] objectAtIndex:0])

//本地Document 目录
#define PATH_OF_DOCUMENT     [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]

#define PATH_OF_LIBRARY      [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) objectAtIndex:0]

//本地Cache 目录
#define PATH_OF_CACHE        [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0]

#define kDEFAULT_DATE_TIME_FORMAT (@"yyyy-MM-dd HH:mm:ss")

#define pic                  @"timeline_image_loading"

#define kImagePlaceholder    [UnitsMethods createImageWithColor:RGBA_COLOR(241, 241, 240, 1)]


#pragma mark - ----------------------Notification macros----------------------

//注册、监听消息
#define kPostNotification(_name) ([[NSNotificationCenter defaultCenter] postNotificationName:_name object:nil userInfo:nil])
#define kPostNotificationWithUserInfo(_name, _obj) ([[NSNotificationCenter defaultCenter] postNotificationName:_name object:nil userInfo:_obj])
#define kAddNotificationObserver(_selector,_name) ([[NSNotificationCenter defaultCenter] addObserver:self selector:_selector name:_name object:nil])


#define kNotificationUserLogined @"kNotificationUserLogined"

#define kNotificationProductNew @"kNotificationProductNew"
//参数包含 productId, status
#define kNotificationProductDelete @"kNotificationProductDelete"
#define kNotificationProductChangeStatusToUndercarriage @"kNotificationProductChangeStatusToUndercarriage"
#define kNotificationProductChangeStatusToSelling @"kNotificationProductChangeStatusToSelling"

#define kNotificationShareNew @"kNotificationShareNew"
#define kNotificationShareDelete @"kNotificationShareDelete"


#pragma mark - ----------------------Font macros----------------------

#define DEFAULT_FONT_48       [UIFont systemFontOfSize:48]
#define DEFAULT_FONT_24       [UIFont systemFontOfSize:24]
#define DEFAULT_FONT_23       [UIFont systemFontOfSize:23]
#define DEFAULT_FONT_22       [UIFont systemFontOfSize:22]
#define DEFAULT_FONT_21       [UIFont systemFontOfSize:21]
#define DEFAULT_FONT_20       [UIFont systemFontOfSize:20]
#define DEFAULT_FONT_19       [UIFont systemFontOfSize:19]
#define DEFAULT_FONT_18       [UIFont systemFontOfSize:18]
#define DEFAULT_FONT_17       [UIFont systemFontOfSize:17]
#define DEFAULT_FONT         [UIFont systemFontOfSize:16]
#define DEFAULT_FONT_15       [UIFont systemFontOfSize:15]
#define DEFAULT_FONT_14       [UIFont systemFontOfSize:14]
#define DEFAULT_FONT_13       [UIFont systemFontOfSize:13]
#define DEFAULT_FONT_12       [UIFont systemFontOfSize:12]
#define DEFAULT_FONT_9       [UIFont systemFontOfSize:9]
#pragma mark - ----------------------Common Font & Color----------------------


#pragma mark - ----------------------REGEX macros----------------------

//@"^1[3|4|5|8][0-9]\\d{8}$"
#define REGEX_ACCOUNT       @"/^([A-Za-z0-9]{8})$/"
#define REGEX_PHONE         @"^\\d{11}$"
#define REGEX_EMAIL         @"^[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%&'*\" + \"+/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?"
#define REGEX_NAME          @"(^[\u4e00-\u9fa5]|[a-z]|[A-Z])[\u4e00-\u9fa5|a-z|A-Z|0-9|\\.|_|\\s]{0,14}[\u4e00-\u9fa5|a-z|A-Z|0-9|\\.|_]$"


#pragma mark - ----------------------frame macros----------------------

//设备屏幕frame
#define kMainScreenFrameRect                           [[UIScreen mainScreen] bounds]
//状态栏高度
#define kMainScreenStatusBarFrameRect                  [[UIApplication sharedApplication] statusBarFrame]
#define kMainScreenHeight                              kMainScreenFrameRect.size.height
#define kMainScreenWidth                               kMainScreenFrameRect.size.width
//减去状态栏和导航栏的高度
#define kScreenHeightNoStatusAndNoNaviBarHeight        (kMainScreenFrameRect.size.height-kMainScreenStatusBarFrameRect.size.height-44.0f)

//减去状态栏和底部菜单栏高度
#define kScreenHeightNoStatusAndNoTabBarHeight         (kMainScreenFrameRect.size.height-kMainScreenStatusBarFrameRect.size.height-49.0f)

//减去状态栏和底部菜单栏以及导航栏高度
#define kScreenHeightNoStatusAndNoTabBarNoNavBarHeight (kMainScreenFrameRect.size.height-kMainScreenStatusBarFrameRect.size.height-49.0f- 44.0f)

//底部工具栏高度
#define kTabBarHeight               49

//导航栏高度
#define kNavBarHeight               44

//左侧间隔
#define kLeftPadding                10

//button边间距
#define kLeftButtonPadding          (10)

#define kImageTargetSize            CGSizeMake(1242, 2208)

#define buttonH 40

#define textFieldH 40

#define textFieldX 10

#define CORNERRADIUS_BUTTON_LITTLE 5

#define Line_Width 0.5

#define Line_Height 0.5

#pragma mark - ----------------------Color Macros----------------------

#define APP_VERSION [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]
#define APP_BUNDLE_VERSION [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]


typedef void(^ResponseCallback)(id result);

#define Color_BG [UIColor whiteColor]
#define Line_Gray_Color [UIColor colorWithRed:0.925 green:0.918 blue:0.929 alpha:1.000]
#define Blue_Color [UIColor colorWithRed:0.000 green:0.157 blue:0.337 alpha:1.000]
#define Text_Gray_Color [UIColor colorWithWhite:0.804 alpha:1.000]
#define Text_Default_Color [UIColor colorWithRed:0.051 green:0.039 blue:0.378 alpha:1.000]


#define STATIC_KEY @"baoxiaoqiang.bcc!"
#define NAMELETTER_PATTERN @"[\u4E00-\u9FA5A-Za-z0-9_]{0,20}"
#define NAME_PATTERN @"[\u4E00-\u9FA5]{2,5}|\\w{2,32}"
#define MOBILE_PATTERN @"^1(3[0-9]|5[012356789]|8[012356789]|47|7[0123456789]|6[0123456789])\\d{8}$"
#define PASSWORD_PATTERN @"[A-Za-z0-9]{6,22}"
#define BANKCARD_PATTERN @"^(\\d{16,19})"
#define NUMBER_PATTERN @"\\d"
